#!/usr/bin/perl

require "./quotamin-lib.pl";
&ReadParse();

my ($dir, $blocktime, $bunits, @gr, $lable, @option_unit, $title);

$dir = $in{"checkeddir"};
$lable = $in{"checkedlable"};

$title = &text('edit_warntime_title', $lable);

&foreign_require("quota", "quota-lib.pl");

@gr = &foreign_call("quota", "get_user_grace", $dir);

&header($title, "", "warntime", 0, 1);

#print "<table class=mode1>";
#print "<p>$text{'edit_warntime_lable'} <b>$lable";
#print "</table>";

print "<form name=form_editwarntime action=index.cgi method=post onsubmit='return onsubmit_form();'>";

print "<table class=mode1 border=0>";
print "<tr><td width=15%>$text{'edit_warntime_blocks_time'}</td>";
print "<td>";
print "<table>";
print "<tr><td><input name=btime size=8 type=text class=text value=\"$gr[0]\"></td>";
print "<td><select name=bunit size=1>";
#@option_unit = ("<option value='0'>$text{'edit_warntime_unit_sec'}", "<option value='1'>$text{'edit_warntime_unit_min'}", "<option value='2'>$text{'edit_warntime_unit_hour'}", "<option value='3'>$text{'edit_warntime_unit_day'}");
@option_unit = ("", "<option value='1'>$text{'edit_warntime_unit_min'}", "<option value='2'>$text{'edit_warntime_unit_hour'}", "<option value='3'>$text{'edit_warntime_unit_day'}");
#if($gr[1] == 0)
#{
#	$option_unit[0] = "<option value='0' selected>$text{'edit_warntime_unit_sec'}";
#}
if($gr[1] == 1)
{
	$option_unit[1] = "<option value='1' selected>$text{'edit_warntime_unit_min'}";
}
elsif($gr[1] == 2)
{
	$option_unit[2] = "<option value='2' selected>$text{'edit_warntime_unit_hour'}";
}
elsif($gr[1] == 3)
{
	$option_unit[3] = "<option value='3' selected>$text{'edit_warntime_unit_day'}";
}

print @option_unit;
print "</select>";
print "</td></tr>";
print "</table>";
print "</td></tr>";

print "<tr><td colspan=2>$text{'edit_warntime_intoduce'}</td></tr>";
print "<tr><td colspan=2>";
print "<table  border=0 class=mode1 celladding=0 cellspacing=10>";
print "<tr><td align=left>";
print "<input name=edit_warntime_submit_ok type=submit class=button1 onclick='return on_submit_ok_click();' value=\"$text{'edit_warntime_submit_ok'}\">";
print "</td><td align=left>";
print "<input name=edit_warntime_submit_cancel type=submit class=button1 onclick='return on_submit_cancel_click();' value=\"$text{'edit_warntime_submit_cancel'}\">";
print "</td></tr>";
print "</table>";
print "</td></tr>";
print "</table>";

print "<input type=hidden name=checkeddir value=\"$dir\">";
print "<input type=hidden name=lable value=\"$lable\">";

print "</form>";

print <<EOF;
<script>

function onsubmit_form()
{
        document.forms[0].edit_warntime_submit_ok.disabled = true;
        document.forms[0].edit_warntime_submit_cancel.disabled = true;
}

function on_submit_ok_click()
{
	document.forms[0].action = "update_user_grace.cgi";
}

function on_submit_cancel_click()
{
	document.forms[0].action = "index.cgi";
}

</script>
EOF

&footer("/", $text{'index'});
